package com.cjr.blog.controller;

import com.cjr.blog.pojo.Article;
import com.cjr.blog.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @Author: chenjianrong
 * @Description:
 * @Data: Create in 23:10 2020/2/5
 * @Modified By:
 */
@Controller
@RequestMapping("/blog")
public class BlogController {

    @Autowired
    private ArticleService articleService;

    @RequestMapping("/index")
    public String index(Model model,
                        @RequestParam(name = "page",required = false,defaultValue = "0") Integer page,
                        @RequestParam(name = "size",required = false,defaultValue = "3") Integer size){
        Page<Article> articlePage = articleService.findAll(page,size);
        model.addAttribute("articlePage",articlePage);
        return "client/index";
    }

}
